/**
 *  Document   : Agency
 *  Created on : 17 juil. 2008, 10:21:37
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "agency")
@NamedQueries({@NamedQuery(name = "Agency.findById", query = "SELECT a FROM Agency a WHERE a.id = :id"),
@NamedQuery(name = "Agency.findByName", query = "SELECT a FROM Agency a WHERE a.name = :name"),
@NamedQuery(name = "Agency.findByLogin", query = "SELECT a FROM Agency a WHERE a.login = :login"),
@NamedQuery(name = "Agency.findByPassword", query = "SELECT a FROM Agency a WHERE a.password = :password")})
public class Agency implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "name")
    private String name;
    @Column(name = "login", nullable = false)
    private String login;
    @Column(name = "password", nullable = false)
    private String password;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refAgency")
//    private Collection<RoomBooking> roomBookingCollection;

    public Agency() {
    }

    public Agency(Integer id) {
        this.id = id;
    }

    public Agency(Integer id, String login, String password) {
        this.id = id;
        this.login = login;
        this.password = password;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

//    public Collection<RoomBooking> getRoomBookingCollection() {
//        return roomBookingCollection;
//    }
//
//    public void setRoomBookingCollection(Collection<RoomBooking> roomBookingCollection) {
//        this.roomBookingCollection = roomBookingCollection;
//    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Agency)) {
            return false;
        }
        Agency other = (Agency) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.Agency[id=" + id + "]";
    }

}
